package oo.poly.dynamic;

import lombok.Getter;

/**
 * @author mubei
 * @date 2021/12/20
 * @description
 */
public class DynamicBinding {

    public static void main(String[] args) {
        //30  动态绑定  getI() B的getI()
        A test = new B();
        System.out.println(test.sum());
    }
}

@Getter
class A{
    int i = 10;

    public int  sum(){
        return getI()+10;
    }

    public int  sum1(){
        return i+10;
    }
}

@Getter
class B extends A {
    int i = 20;


    @Override
    public int sum1() {
        return getI()+20;
    }
}
